package com.sec.android.app.myfiles.mockclass;

import android.database.Cursor;

import org.powermock.api.mockito.PowerMockito;

import static org.powermock.api.mockito.PowerMockito.when;

/**
 * Created by jaebae on 2016-07-05.
 */
public class CursorMock {
    public static Cursor createCursor(int count) {
        Cursor ret = PowerMockito.mock(Cursor.class);

        when(ret.getCount()).thenReturn(count);
        when(ret.moveToFirst()).thenReturn(true);
        return ret;
    }

    public static void addColumnIndex(Cursor cursor, String columnName, int index) {
        when(cursor.getColumnIndex(columnName)).thenReturn(index);
    }

    public static void addIntValue(Cursor cursor, int index, int value) {
        when(cursor.getInt(index)).thenReturn(value);
    }

    public static void addLongValue(Cursor cursor, int index, long value) {
        when(cursor.getLong(index)).thenReturn(value);
    }

    public static void addStringValue(Cursor cursor, int index, String value) {
        when(cursor.getString(index)).thenReturn(value);
    }
}
